package test9;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class zuida {
	public static void main(String[] args){
		Set<String> set=new HashSet<>();
		Scanner sr=new Scanner(System.in);
		/*while(sr.hasNext()){
			String word=sr.next();
			set.add(word);
			
		}*/
		String str = sr.nextLine();
		String []word = str.split(" ");
        for (int i = 0; i <word.length ; i++) {
            set.add(word[i]);
        }
		System.out.println(set.toString());
		while(sr.hasNext()){
			String line=sr.nextLine();
			List<String> list=new ArrayList<String>();
			int i=line.length();
			while(i>0){				
				for(int j=i-1;j>=0;j--){
					if(set.contains(line.substring(j,i))){
						list.add(line.substring(j, i));
						//System.out.println(line.substring(j, i));
						i=j;
						j=i-1;
						continue;						
					}
				}
			}
			for(i=list.size()-1;i>=0;i--){
				System.out.print(list.get(i)+" ");
			}
			System.out.println();
		}
		
	}
	

}
